<?php
// 应用公共文件
use Firebase\JWT\JWT;
use Firebase\JWT\Key;


function makeJwtToken($data,$key='tpFeng365'){
    $payload = array(
        'iss'=>'http://tp6.com',
        'aud'=>'http://tp6.com',
        'iat'=>time(),
        'nbf'=>time(),
        'exp'=>time() + 3600*24*7,
        'data'=>$data
    );
    $token = JWT::encode($payload,$key,'HS256');
    return $token;
}

function decodeJwtToken($token,$key='tpFeng365'){
    $result = JWT::decode($token,new Key($key,'HS256'));
    return ((array) $result);
}

function ftime($format = 'Y-m-d H:i:s'){
    return date($format);
}

function millisecond(){
    return round(microtime(true)*1000);
}


